package no.uib.kwikktaim.gui.actionlisteners;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

import no.uib.kwikktaim.gui.MainWindow;

public class ListManipulationListener implements MouseListener,ListSelectionListener, KeyListener {
	MainWindow mw;

	public ListManipulationListener(MainWindow mw) {
		this.mw = mw;
	}

	@Override
	public void mouseClicked(MouseEvent e) {
		//change track
		if(e.getClickCount() == 2) {
			mw.loadAndPlay();
		}
	}

	@Override
	public void mouseEntered(MouseEvent e) {
	}

	@Override
	public void mouseExited(MouseEvent e) {
	}

	@Override
	public void mousePressed(MouseEvent e) {
	}

	@Override
	public void mouseReleased(MouseEvent e) {
	}

	@Override
	public void valueChanged(ListSelectionEvent e) {
	}

	@Override
	public void keyPressed(KeyEvent e) {
		if(e.getKeyCode() == KeyEvent.VK_DELETE) {
			mw.removeMediaFromPlayList(); // Delete file
		}
		else if(e.getKeyCode() == KeyEvent.VK_ENTER) {
			mw.loadAndPlay(); // Play file
		}
	}

	@Override
	public void keyReleased(KeyEvent e) {

	}

	@Override
	public void keyTyped(KeyEvent e) {

	}

}
